from apscheduler.schedulers.background import BackgroundScheduler

from cola.consumers import connected


# 为所有用户的界面生成尘埃
def render():
    for group in connected.values():
        if 'users' not in group or not group['users']:
            continue
        user = list(group['users'].values())[0]
        user.drop()


# 初始化定时器
def init():
    scheduler = BackgroundScheduler()
    # 每39秒执行一次
    scheduler.add_job(render, 'interval', seconds=1)
    # scheduler.start()
